package com.itheima.test;



import java.util.ArrayList;
import java.util.Scanner;

public class Student {

    private String id;
    private String name;
    private int age;
    private String birthday;

    public Student() {
    }

    public Student(String id, String name, int age, String birthday) {
        this.id = id;
        this.name = name;
        this.age = age;
        this.birthday = birthday;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getBirthday() {
        return birthday;
    }

    public void setBirthday(String birthday) {
        this.birthday = birthday;
    }



    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        //用来充当整个系统的数据容器
      ArrayList<Student> list=new ArrayList();

        lo:
        while (true) {

            //搭建主界面菜单
            System.out.println("------欢迎来到学生管理系统------");
            System.out.println("1 添加学生");
            System.out.println("2 删除学生");
            System.out.println("3 修改学生");
            System.out.println("4 查看学生");
            System.out.println("5 退出");
            System.out.println("请输入您的选择");

            String choice = sc.next();

            switch (choice) {
                case "1":
                   addStudent(list);
                    //System.out.println("添加学生");
                    break;
                case "2":
                    System.out.println("删除学生");
                    break;
                case "3":
                    System.out.println("修改学生");
                    break;
                case "4":
                    queryStudent(list);
                    System.out.println("查看学生");
                    break;
                case "5":
                    System.out.println("感谢您的使用！");
                    break lo;
                default:
                    System.out.println("您的输入有误");

            }

        }


    }


    //添加学生的方法
    private static void addStudent(ArrayList<Student> list) {
        Scanner sc = new Scanner(System.in);
        //1.给出录入的提示信息
        System.out.println("请输入学号");
        String id = sc.next();
        System.out.println("请输入姓名");
        String name = sc.next();
        System.out.println("请输入年龄");
        int age = sc.nextInt();
        System.out.println("请输入生日");
        String birthday = sc.next();
        //2.将键盘录入的信息封装为学生对象
        Student stu=new Student(id,name,age,birthday);
        //3.将封装好的学生对象，添加到集合容器当中
          list.add(stu);
        //4.给出添加成功的提示信息
        System.out.println("添加成功！");
    }

    //查看学生的方法
    private static void queryStudent(ArrayList<Student> list) {
            //判断集合中是否有数据，如果不存在给出提示
            if (list.size()==0){
                System.out.println("无信息，请添加后重新查询");
                return;
            }
            //存在，展示表头数据
        System.out.println("学号\t\t姓名\t年龄\t生日");
            //遍历集合，获取每一个学生对象的信息，并打印在控制台
        for (int i = 0; i < list.size(); i++) {
           Student stu=list.get(i);
            System.out.println(stu.getId()+"\t"+stu.getName()+"\t"+stu.getAge()+"\t\t"+stu.getBirthday());
        }
    }




}





